<?php
namespace Visitors;

use Visitors\VisitsInfo;
use Visitors\Visits;

/**
 * Выводим информацию о посещениях профиля
 */
class InfoAction extends \Action //VisitorCountAction
{
  protected function run()
  {
    // find profile if exist
	$profile = VisitsInfo::find()->where('profile._ref',(string)$this->request->owner)->one();
	//print_r($profile);exit;
	if(is_object($profile)){

	//call function for recounting guests    
	$profile->reCounter(); 
	
	$this->response->counterOfDay = $profile->profileVisitorsByDay;
  	$this->response->counterOfWeek = $profile->profileVisitorsByWeek;
  	$this->response->counterOfMonth = $profile->profileVisitorsByMonth;
  	
  	
	}else {
	    
        $this->response->counterOfDay = 0;
	    $this->response->counterOfWeek = 0;
	    $this->response->counterOfMonth = 0;
	     
	}
  }
}